package com.alpha.eceasy.mall.client;

//import io.swagger.annotations.ApiModel;
//import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.UUID;

/**
 * -结果返回统一格式
 *
 * @author Xls
 */
@Deprecated
@Data
@NoArgsConstructor
//(description = "返回类")
public class ResponseData<T> implements Serializable {

	private String request;
	//Property(value = "接口唯一标识")
	private boolean success;
	//Property(value = "状态码", example = "200")
	private int code;
	//Property(value = "状态描述")
	private String message;
	//Property(value = "返回内容")
	private T data;

	public static <T> ResponseData<T> failed(int code, String message) {
		return new ResponseData<T>(false, code, message, null);
	}

	public static <T> ResponseData<T> failed(T entity, int code, String message) {
		return new ResponseData<T>(false, code, message, entity);
	}

	public ResponseData(boolean success, int code, String message, T data) {
		this.request= UUID.randomUUID().toString();
		this.success = success;
		this.code = code;
		this.message = message;
		this.data = data;
	}

	public static <T> ResponseData<T> failed(String message) {
		return new ResponseData<T>(false, -1, message, null);
	}
	public static <T> ResponseData<T> failed(String message, T data) {
		return new ResponseData<T>(false, -1, message, data);
	}


	public static <T> ResponseData<T> successReturnData(T data) {
		return success(data, "success");
	}
	public static <T> ResponseData<T> successReturnMsg(String message) {
		return success(null, message);
	}
	public static <T> ResponseData<T> success(T data) {
		return success(data, "success");
	}
	public static <T> ResponseData<T> success(T data, String message) {
		return new ResponseData<T>(true, 0, message, data);
	}
	public static <T> ResponseData<T> successMsg(String msg) {
		return success(null ,msg);
	}
}
